//Tue Apr 26 09:35:09 CDT 2011
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>

using namespace std;

class ComparerInator {
public:
	int makeProgram(vector<int> A, vector<int> B, vector<int> wanted) {
		if (program1(A, B, wanted) || program2(A, B, wanted))
			return 1;
		if (program3(A, B, wanted) || program4(A, B, wanted))
			return 7;
		return -1;
	}
	bool program1(vector<int> A, vector<int> B, vector<int> C) {
		int N = A.size();
		for (int i = 0; i < N; i++)
			if (A[i] != C[i])
				return false;
		return true;
	}
	bool program2(vector<int> A, vector<int> B, vector<int> C) {
		int N = A.size();
		for (int i = 0; i < N; i++)
			if (B[i] != C[i])
				return false;
		return true;
	}
	bool program3(vector<int> A, vector<int> B, vector<int> C) {
		int N = A.size();
		for (int i = 0; i < N; i++)
			if (A[i] < B[i] && A[i] == C[i])
				continue;
			else if (A[i] >= B[i] && B[i] == C[i])
				continue;
			else
				return false;
		return true;
	}
	bool program4(vector<int> A, vector<int> B, vector<int> C) {
		int N = A.size();
		for (int i = 0; i < N; i++)
			if (A[i] < B[i] && B[i] == C[i])
				continue;
			else if (A[i] >= B[i] && A[i] == C[i])
				continue;
			else
				return false;
		return true;
	}
};

